﻿#include "FITKAbaqusPostData.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include "FITK_Interface/FITKInterfaceStructuralPost/FITKStruPost3DManager.h"
#include "FITK_Interface/FITKInterfaceStructuralPost/FITKStruPostSetting.h"
#include "FITK_Interface/FITKInterfaceStructuralPost/FITKStruPostDisplayGroup.h"

namespace AbaqusData
{

    FITKAbaqusPostData::FITKAbaqusPostData()
    {
        //创建对象
        _postSetting = new Interface::FITKStruPostSetting;
        _post3DManager = new Interface::FITKStruPost3DManager;
        _postGroupManager = new Interface::FITKPostGroupManager;
    }

    FITKAbaqusPostData::~FITKAbaqusPostData()
    {
        //释放内存
        if (_postSetting) delete _postSetting;
        if (_post3DManager) delete _post3DManager;
        if (_postGroupManager) delete _postGroupManager;
    }

    FITKAbaqusPostData* FITKAbaqusPostData::GetDataFromAPPFrame()
    {
        if (FITKAPP == nullptr) return nullptr;
        auto  gloData = FITKAPP->getGlobalData();
        if (gloData == nullptr) return nullptr;
        //强制类型转换
        return gloData->getPostData<FITKAbaqusPostData>();
    }

    Interface::FITKStruPostSetting* FITKAbaqusPostData::getPostSetting()
    {
        return _postSetting;
    }

    Interface::FITKStruPost3DManager* FITKAbaqusPostData::getPost3DManager()
    {
        return _post3DManager;
    }

    Interface::FITKPostGroupManager* FITKAbaqusPostData::getPostDisplayGroupManager()
    {
        // 全部后处理数据对象的显示分组管理器。
        return _postGroupManager;
    }

    int FITKAbaqusPostData::getCurrentPostDisplayGroupDataID()
    {
        if (!_postGroupManager)
        {
            return -1;
        }

        // 获取激活的显示分组数据ID。
        return _postGroupManager->getCurrentGroupID();
    }

    void FITKAbaqusPostData::setCurrentPostDisplayGroupDataID(const int id)
    {
        if (!_postGroupManager)
        {
            return;
        }

        // 保存激活的显示分组ID。
        _postGroupManager->setCurrentGroupID(id);
    }

    int FITKAbaqusPostData::getCurrentPostDataID()
    {
        return _currentDataID;
    }

    void FITKAbaqusPostData::setCurrentPostDataID(const int id)
    {
        _currentDataID = id;
    }

}
